package com.flyou.ccnucenter.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.flyou.ccnucenter.R;
import com.flyou.ccnucenter.domain.News;
import com.flyou.ccnucenter.utils.SPUtils;

import java.util.List;

/**
 * ============================================================
 * 项目名称：HenuCenterPro
 * 包名称：com.flyou.flying.adapter
 * 文件名：SchoolAdapter
 * 类描述：
 * 创建人：flyou
 * 邮箱：fangjaylong@gmail.com
 * 创建时间：2015/11/17 14:15
 * 修改备注：
 * 版本：@version  V1.0
 * ============================================================
 */
public class SchoolAdapter extends SimpleBaseAdapter<News> {
    private Context mContex;
    private List<News> mNewses;
    public SchoolAdapter(Context context, List<News> data) {
        super(context, data);
        this.mContex = context;
        this.mNewses = data;
    }

    @Override
    public int getItemResource() {
        return R.layout.school_news_item;
    }

    @Override
    public View getItemView(int position, View convertView, ViewHolder holder) {
        TextView textView = holder.getView(R.id.news_title);
//        标注本地是否具有页面缓存，有的话就设置为灰色

        News news=new News();
        Object item = getItem(position);
        news=(News)item;
        String newsContent = (String) SPUtils.get(context, news.getUrl(), "");
        textView.setTextColor(Color.BLACK);
        if (!TextUtils.isEmpty(newsContent)){
            textView.setTextColor(Color.GRAY);
        }
        textView.setText(data.get(position).getTitle());
        return convertView;
    }
}
